package com.ljh.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;

import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration //配置
@EnableSwagger2 //开启swagger
public class SwaggerConfig {


    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)//配置了Swagger的bean实例
                .apiInfo(apiInfo())
                .select()
                //RequestHandlerSelectors 配置要扫描的接口的方法
                //basePackage 指出要扫描的包
                //ang():扫描全部
                //none:一个都不扫描
                //withClassAnnotation: 扫描类上的注解
                //withMethodAnnotation: 扫描方法上的注解
                // .apis(RequestHandlerSelectors.withMethodAnnotation(GetMapping.class))
                .apis(RequestHandlerSelectors.basePackage("com.ljh.controller"))
//                .paths(PathSelectors.ant("/ljh"))//过滤什么路径
                //参数:
                //ant : 路径
                //none:一个也不
                //any:全部
                //regex:正则
                .build();
    }
    //配置Swagger信息
    public ApiInfo apiInfo() {
        //name url email 作者信息
        Contact contact = new Contact("Jiahao Li", "https://gitee.com/ljhkgf", "1196915419@qq.com");

        return new ApiInfo("云音乐播放平台管理接口端",
                "微信小程序",
                "1.0",
                "https://gitee.com/ljhkgf",
                contact, "" +
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }


}